package com.bfmet.servlet;

import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.OutputStream;

import javax.imageio.ImageIO;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
//import javax.servlet.annotation.WebServlet;

import com.bfmet.common.base.ServletBase;

//@WebServlet("/themeservlet/*")
public class ThemeServlet extends ServletBase {

	protected void doGet(ServletRequest request, ServletResponse response)
			throws ServletException, IOException {
		try {
			BufferedImage image = new BufferedImage(400, 170,
					BufferedImage.TYPE_INT_RGB);

			Graphics2D g = image.createGraphics();
			int w = 400;
			int h = 170;
			g.setPaint(new GradientPaint(0, 0, Color.white, w, h, Color.blue));
			g.fillRect(0, 0, w, h);

			response.setContentType("image/png");
			OutputStream os = response.getOutputStream();
			ImageIO.write(image, "png", os);
			os.close();
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}

}
